# -*- coding: utf-8 -*-
from datetime import timedelta
from utils.operators.cluster_for_spark_sql_hook_test_for_airflow_bug_operator import SparkSqlOperator

#from jms.dim.dim_network_whole_massage import jms_dim__dim_network_whole_massage
#from jms.dim.dim_first_second_third_code_info import jms_dim__dim_first_second_third_code_info
#from jms.dwd.tab.dwd_tab_barscan_centerarrival_base_dt import jms_dwd__dwd_tab_barscan_centerarrival_base_dt
#from jms.dwd.tab.dwd_tab_barscan_centersend_base_dt import jms_dwd__dwd_tab_barscan_centersend_base_dt
#from jms.dwd.oms.dwd_yl_oms_oms_waybill_incre_dt import jms_dwd__dwd_yl_oms_oms_waybill_incre_dt
#from jms.time_sensor.time_after_04_45 import time_after_04_45
#from jms.dim.sqs.dim_problem_express_wo_record_base import jms_dim__dim_problem_express_wo_record_base

dm__dm_transfor_network_package_detail = SparkSqlOperator(
    task_id='dm__dm_transfor_network_package_detail',
    pool_slots=5,
    task_concurrency=1,  # 如果任务不支持并发，则将 task_concurrency 设为 1
    name='dm__dm_transfor_network_package_detail_{{ execution_date | date_add(1) | cst_ds }}',
    sql='jms_route_test/dm/dm_transfor_network_package_detail/execute.hql',
    driver_memory='4G',
    executor_memory='12G',
    executor_cores=8,
    num_executors=16,
    email=['guoruiling@jtexpress.com','yl_bigdata@yl-scm.com'],
    conf={'spark.executor.memoryOverhead': 4096,
          'spark.core.connection.ack.wait.timeout': 5000,
          'spark.default.parallelism': 400,
          'spark.sql.shuffle.partitions': 400,
          'spark.locality.wait': 60,
          'spark.driver.maxResultSize': 20,
          'spark.dynamicAllocation.enabled': 'true',  # 动态资源开启
          'spark.shuffle.service.enabled':'true',
          'spark.dynamicAllocation.maxExecutors': 20,  # 动态资源最大扩容 Executor 数
          'spark.executor.extraJavaOptions': '-XX:+UseG1GC -XX:ParallelGCThreads=8',
          },
    execution_timeout=timedelta(minutes=120),
    hiveconf={'hive.exec.dynamic.partition': 'true',  # 动态分区
              'hive.exec.dynamic.partition.mode': 'nonstrict',
              'hive.exec.max.dynamic.partitions': 10,  # -表示一个动态分区语句可以创建的最大动态分区个数，超出报错
              'hive.exec.max.dynamic.partitions.pernode': 10,  # 默认100，一般可以设置大一点，比如1000。表示每个maper或reducer可以允许创建的最大动态分区个数，默认是100，超出则会报错。
              },
    yarn_queue='pro',
)

dm__dm_transfor_network_package_detail << [
    #jms_dim__dim_first_second_third_code_info,
    #jms_dwd__dwd_yl_oms_oms_waybill_incre_dt,
    #jms_dim__dim_network_whole_massage,
    #jms_dwd__dwd_tab_barscan_centerarrival_base_dt,
    #jms_dwd__dwd_tab_barscan_centersend_base_dt,
    #time_after_04_45,
    #jms_dim__dim_problem_express_wo_record_base
]
